package cn.blogsx;
/*
静态代理举例
特点：在程序编译时就已经确定代理类和被代理类了
 */
interface ClothFactory {
    void produceCloth();
}
//代理类
class ProxyClothFactory implements ClothFactory {

    private ClothFactory factory; //用被代理类进行实例化

    public ProxyClothFactory(ClothFactory factory) {
        this.factory = factory;
    }

    @Override
    public void produceCloth() {
        System.out.println("代理工厂做一些准备工作");
        factory.produceCloth();
        System.out.println("代理工厂做一些后续的收尾工作");

    }
}
//被代理类
class NickClothFactory implements ClothFactory {

    @Override
    public void produceCloth() {
        System.out.println("nick工厂生产一批羽绒服");
    }
}
public class StaticProxyDemo1 {
    public static void main(String[] args) {
        //被代理类对象
        ClothFactory nick = new NickClothFactory();
        //代理类对象
        ClothFactory proxyClothFactory = new ProxyClothFactory(nick);

        proxyClothFactory.produceCloth();
    }
}
